import { EditOutlined } from "@ant-design/icons";
import type { MenuProps } from "antd";
import { Dropdown } from "antd";
import { MenuButton } from "./MenuButton.tsx";

const items: MenuProps["items"] = [
  { key: "anchors", label: "添加/删除锚点(A)" },
  { key: "addAchievement", label: "添加手柄(H)" },
  { key: "deleteAchievement", label: "删除手柄(D)" },
  { key: "switchAchievementType", label: "切换手柄类型(shift)" },
];
export const EditDropDown = () => {
  const onClick: MenuProps["onClick"] = ({ key }) => {
    switch (key) {
      case "anchors":
        window.meta2d.toggleAnchorMode();
        break;
      case "addAchievement":
        window.meta2d.addAnchorHand();
        break;
      case "deleteAchievement":
        window.meta2d.removeAnchorHand();
        break;
      case "switchAchievementType":
        window.meta2d.toggleAnchorHand();
        break;
      default:
        break;
    }
  };
  return (
    <>
      <Dropdown arrow menu={{ items, onClick }}>
        <a onClick={(e) => e.preventDefault()}>
          <MenuButton
            arrow
            children={<EditOutlined />}
            title="编辑"
          ></MenuButton>
        </a>
      </Dropdown>
    </>
  );
};
